 //
//  main.m
//  KVC
//
//  Created by J on 15/11/22.
//  Copyright © 2015年 J. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Person.h"
#import "Dog.h"
int main(int argc, const char * argv[]) {
    @autoreleasepool {
        // insert code here...
    
        Person * p =[Person new];
        
//        p.name = @"jzj";
//        p.age = 14;
        
//        [p setValue:@"jzj" forKey:@"name"];//value只能放对象
//        [p setValue:@200 forKey:@"age"];//基本数据类型包装成对象NSNumber

        
        //利用KVC 随意修改一个对象的属性或者成员变量
//        [p setValue:@"jzj" forKeyPath:@"_name"];//value只能放对象
//        [p setValue:@200 forKeyPath:@"age"];//基本数据类型包装成对象NSNumber
        
//        [p setValue:@2990 forKeyPath:@"height"];//基本数据类型包装成对象NSNumber [p valueForKey:@"height"]取得时候也是用%@
//
//        NSLog(@"%d %@ %@",p.age,p.name,[p valueForKey:@"height"]);

        
        p.dog = [[Dog alloc]init];
        [p setValue:@"dog66" forKeyPath:@"dog.name"];
        NSLog(@"%@",[p  valueForKeyPath:@"dog.name"]);
        
        
        
    }
    return 0;
}
